import { defHttp } from '/@/utils/http/axios';
import { LoginParams, LoginResultModel } from './model/authModel';

import { ErrorMessageMode } from '/#/axios';

enum Api {
  Login = '/shop-auth/oauth/token',
  Logout = '/shop-auth/oauth/logout',
}

/**
 * @description: user login api
 */
export function loginApi(params: LoginParams, mode: ErrorMessageMode = 'modal') {
  return defHttp.post<LoginResultModel>(
    {
      url: Api.Login,
      params,
    },
    {
      errorMessageMode: mode,
    },
  );
}

export function doLogout() {
  return defHttp.delete({ url: Api.Logout });
}
